#!/usr/bin/python3
# -*- coding: utf-8; tab-width: 4; indent-tabs-mode: t -*-

import glob
import pathlib

try:
    for fn in glob.glob("*.ebuild"):
        buf = pathlib.Path(fn).read_text()

        # remove dep
        buf = buf.replace("acct-group/netdev\n", "")

        # insert
        pos = buf.find("--enable-gobject\n")
        if pos == -1:
            raise ValueError()
        pos += len("--enable-gobject\n")
        buf = buf[:pos] + "\t\t--with-avahi-priv-access-group=wheel\n" + buf[pos:]

        # do write
        with open(fn, "w") as f:
            f.write(buf)
except ValueError:
    print("outdated")
